package com.tong.hao.cron.scheduler;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName ScheduleTask
 * @Author 友野浩二
 * @Date 2019/11/24 13:23
 * @Description 定时任务
 * @Version 1.0
 */
@Component
public class ScheduleTask {

    private int index = 0;

    /**
     * @Author 友野浩二
     * @Description // 定时任务栗子: 每5秒执行一次Task
     * @Date 2019/11/24 13:34
     * @Param []
     * <pre>
     * @Scheduled 注解 支持cron表达式
     *      cron表达式格式: [秒] [分] [时] [日] [月] [周] [年]
     * </pre>
     **/
    @Scheduled(cron = "*/5 * * * * *")
    public void process() {
        System.err.println("this is scheduler task running: " + (index++));
    }

}
